{include file='public/head'}
<body>
<style type="text/css" media="screen">
    header {
        color: black;
    }
</style>


<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="address">
        <input type="hidden" name="id" value="{$order.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">
                收货人
            </label>
            <div class="layui-input-block">
                <input type="text" id="receiver_name" value="{$order.receiver_name}" name="receiver_name" lay-verify="required"
                       autocomplete="off" placeholder="请输入收货人" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">国&nbsp;&nbsp;&nbsp;家</label>
            <div class="layui-input-block">
                <select name="receive_nation_id" id='receive_nation_id' lay-verify="required" lay-filter="receive_nation_id">
                    {php}
                    foreach($nation as $vo){
                    if($vo['id']==$order['receive_nation_id']){
                    {/php}
                    <option value="{$vo.id}" title="{$vo.name}" selected>{$vo.short}&nbsp;{$vo.name}</option>
                    {php} }else{ {/php}
                    <option value="{$vo.id}" title="{$vo.name}">{$vo.short}&nbsp;{$vo.name}</option>
                    {php} } } {/php}
                </select>
                <input type="hidden" id="receive_nation" name="receive_nation" value="{$order.receive_nation}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">州&nbsp;&nbsp;&nbsp;省</label>
            <div class="layui-input-block">
                <input type="text" id="receiver_province" value="{$order.receiver_province}" name="receiver_province"
                       lay-verify="required" placeholder="请输入州/省" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">城&nbsp;&nbsp;&nbsp;市</label>
            <div class="layui-input-block">
                <input type="text" id="receiver_city" value="{$order.receiver_city}" name="receiver_city"
                       lay-verify="required" placeholder="请输入城市名" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">详细地址</label>
            <div class="layui-input-block">
                <input type="text" id="receiver_address" value="{$order.receiver_address}" name="receiver_address"
                       lay-verify="required" placeholder="请输入详细地址" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">电&nbsp;&nbsp;&nbsp;话</label>
            <div class="layui-input-block">
                <input type="text" id="receiver_phone" value="{$order.receiver_phone}" name="receiver_phone"
                       lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邮&nbsp;&nbsp;&nbsp;编</label>
            <div class="layui-input-block">
                <input type="text" id="receiver_zip" value="{$order.receiver_zip}" name="receiver_zip"
                       lay-verify="required" placeholder="请输入注册邮箱" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邮&nbsp;&nbsp;&nbsp;箱</label>
            <div class="layui-input-block">
                <input type="text" id="receiver_email" value="{$order.receiver_email}" name="receiver_email"
                       lay-verify="required" placeholder="请输入联系邮箱" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div>
                <button style="width: 100%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交保存</button>
            </div>
        </div>

    </form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">
    var form = layui.form;

    form.on('select(receive_nation_id)', function(data){
        var receive_nation = data.elem[data.elem.selectedIndex].title;
        $("#receive_nation").val(receive_nation);
    });
    $(document).ready(function () {
        var form = layui.form;
        var layer = layui.layer;
        var options = {
            type: 'post',           //post提交
            // url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
            dataType: "json",        //json格式
            data: {},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache: false,
            async: false,          //同步返回
            success: function (data) {
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        $("#reset").click();
                        x_admin_close();
                        parent.location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        // bind form using 'ajaxForm'
        $('#mainForm').ajaxForm(options).submit(function (data) {
        });
    });
</script>
</html>
